package com.yang.designmode.ActionMode.interpreter;

import java.util.HashMap;
import java.util.Map;

class Context {
    private Map<String, Integer> variables = new HashMap<>();

    // 设置变量值
    public void setVariable(String name, int value) {
        variables.put(name, value);
    }

    // 获取变量值
    public int getVariable(String name) {
        Integer value = variables.get(name);
        if (value == null) {
            throw new IllegalArgumentException("变量 " + name + " 未定义");
        }
        return value;
    }
}

